﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using FJASPX.Framwork.UI;
using FJASPX.Service;
using FJASPX.Framwork.Helper;
using FJASPX.Framwork.Constant;
using ExtAspNet;

namespace PlugNT.Cms.Web.Member
{
    public partial class Default : EditPageBase<FJASPX.Domain.User>
    {
        public IUserService iUserService { get; set; }

        #region Property属性
        public override string PowerCode
        {
            get { throw new NotImplementedException(); }
        }
        #endregion

        #region Methods方法


        protected override bool FirstCallRead()
        {
            //初始化控件
            base.FirstCallRead();
            this.btn_Info.Text = this.CurrentUser.UserName;

            this.Model = iUserService.GetUserByName(this.CurrentUser.UserName);
            if (!this.Model.IsNull())
            {
                this.txt_Infos.SetValue(this.Model.CompanyInfo);
                ExtAspNet.TreeNode treeNode = new ExtAspNet.TreeNode();
                treeNode.Text = "浏览店铺";
                treeNode.Target = "_blank";
                treeNode.NavigateUrl = "Store/Look.aspx";
                treeNode.IconUrl = "/Icons/database_yellow.png";
                treeNode.OnClientClick = "javascript:window.open('/home" + this.Model.Id + ".aspx ');";
                this.tree_MHome.Nodes.Insert(1, treeNode);
            }

            return true;
        }
        #endregion

        #region Events事件
        protected void btn_Reload_Click(object sender, EventArgs e)
        {

        }
        protected void tir_Main_Tick(object sender, EventArgs e)
        {

        }

        protected void btn_EndLogin_Click(object sender, EventArgs e)
        {
            ExtAspNet.PageContext.Redirect("/LoginOut.aspx");
        }

        protected void btn_UserInfo_Click(object sender, EventArgs e)
        {
            Page.Response.RedirectLocation = "/Personal/Default.aspx";
        }


        protected void btn_Update_Click(object sender, EventArgs e)
        {
            this.Model = iUserService.GetUserByName(this.CurrentUser.UserName);
            if (!this.Model.IsNull())
            {
                this.Model.CompanyInfo = this.txt_Infos.GetValue();
                iUserService.Update(this.Model);
            }
        }
        protected void btn_ChangePassword_Click(object sender, EventArgs e)
        {
            PageContext.RegisterStartupScript(win_ChangePassword.GetShowReference());
        }
        #endregion


    }
}